/* $RCSFile: ADNDynQuote.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynQuote.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:33  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynQuote : ADNDynSalesBase
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.quote)
            {}

            public override Type DynType
            { get { return typeof(ADNDynQuote); } }

            public override string DynTypename
            {   get{ return CrmStr.quote;}}

            public override DynEntity Build()
            {   return new ADNDynQuote();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynQuote(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynQuote(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynQuote(w,PrimaryKeyValue);}
        }

        static ADNDynQuote(){new Ftor();} 


        /// <summary>
		/// Reserved for template methods: do not use directly
		/// </summary>
        public ADNDynQuote(): base()
		{}

        public ADNDynQuote(CRMWrapperBase w, string PrimaryFiedlValue)
			: base(w,CrmStr.quote)
		{
			name = PrimaryFiedlValue;
		}

		public ADNDynQuote(CRMWrapperBase w, Guid CrmId)
			: base(w,CrmStr.quote, CrmId)
		{}

		public ADNDynQuote(CRMWrapperBase w, InternalDynamicEntity e)
			: base(w,CrmStr.quote,e,null,null)
		{}

		public ADNDynQuote(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(w,CrmStr.quote,e,prop,s)
		{}

        public ADNDynQuote(ResetWrapperHandler fn, string PrimaryFiedlValue)
			: base(fn,CrmStr.quote)
		{
			name = PrimaryFiedlValue;
		}

		public ADNDynQuote(ResetWrapperHandler fn, Guid CrmId)
			: base(fn,CrmStr.quote, CrmId)
		{}

		public ADNDynQuote(ResetWrapperHandler fn, InternalDynamicEntity e)
			: base(fn,CrmStr.quote,e,null,null)
		{}

		public ADNDynQuote(ResetWrapperHandler fn, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)
			: base(fn,CrmStr.quote,e,prop,s)
		{}
    
        /// <summary>
		/// Crm Key
		/// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public Guid quoteid
		{
			get
			{
				return KeyPropertyValue(CrmStr.quoteid);
			}
			set
			{
				AddKeyProperty(CrmStr.quoteid, value);
			}
		}

        protected override void SetCrmIdProperty(Guid crmId)
        {
           if ( !dicProperty.ContainsKey(CrmStr.quoteid) || KeyPropertyValue(CrmStr.quoteid) != crmId )
                quoteid =   crmId;
        }

        public override Guid PrimaryKeyGuidValue
        {
           get
           {
                return quoteid;
           }
           set
           {
               quoteid    =   value;
           }
        }

        /// <summary>
        /// Gets or sets the order number.  
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public string quotenumber
        {
            get
            {
                return StringPropertyValue(CrmStr.quotenumber);
            }
            set
            {
                AddStringProperty(CrmStr.quotenumber,value);
            }
        }

        /// <summary>
        /// Gets the revision number for the quote. 
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public int revisionnumber
        {
            get
            {
                return NumberPropertyValue(CrmStr.revisionnumber);
            }
            set
            {
                AddNumberProperty(CrmStr.revisionnumber,value);
            }
        }

        /// <summary>
        /// Gets or sets the date and time when the quote becomes effective. 
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public string effectivefrom
        {
            get
            {
                return DateTimePropertyValue(CrmStr.effectivefrom);
            }
            set
            {
                AddDateTimeProperty(CrmStr.effectivefrom,value);
            }
        }
 
        /// <summary>
        /// Gets or sets the date that is the last day the quote is in effect. 
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public string effectiveto
        {
            get
            {
                return DateTimePropertyValue(CrmStr.effectiveto);
            }
            set
            {
                AddDateTimeProperty(CrmStr.effectiveto,value);
            }
        }
      
        /// <summary>
        /// Gets or sets the date when the quote expires.   
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public string expireson
        {
            get
            {
                return DateTimePropertyValue(CrmStr.expireson);
            }
            set
            {
                AddDateTimeProperty(CrmStr.expireson,value);
            }
        }

        /// <summary>
        /// virtual because on 'detail' records it is only a uniqueidentifier property
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public Guid owningbusinessunit
        {
            get
            {
                return LookupPropertyValue(CrmStr.owningbusinessunit);
            }
            set
            {
                AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value);
            }
        }
        
        /// <summary>
        /// Owner for this object
        /// </summary>
        [CrmDynAttribute(CrmStr.quote)]
        public override Guid ownerid
        {
            get
            {
                if ( ContainsKey(CrmStr.ownerid) )
                    return OwnerPropertyValue(CrmStr.ownerid);
                return Guid.Empty;
            }
            set
            {
                AddOwnerProperty(CrmStr.ownerid,CrmStr.systemuser,value);
            }
        }
    }
}
